<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>fileInfo生成小工具</title>
    <style type="text/css">
        body {
            text-align: center
        }

        div {
            display: inline-block;
            width: 90%;
            border: solid 1px #6BBE18;
            text-align: center;
            font-weight: bold;
        }

        span {
            display: block;
            text-align: center;
            margin: 30px 0 30px 0;
        }

        table {
            border-collapse: collapse;
            display: inline-block;
            text-align: center;
            margin: 0px 0 30px 0;
        }

        td, th {
            border: solid 2px #6BBE18;
            width: 300px;
        }

        tr {
            height: 40px;
        }

        .close {
            display: none;
        }

    </style>


    <script type="text/javascript">
        Array.prototype.contains = function (obj) {
            var index = this.length;
            while (index--) {
                if (this[index] === obj) {
                    return true;
                }
            }
            return false;
        }


        function control(a) {
            var id = a.id + "_value";
            var value = document.getElementById(id);
            //alert("1."+value);
            if (value.className == "" || value.className == null) {
                value.className = "close";
                var input = value.getElementsByTagName("input");
                for (var i = 0; i < input.length; i++) {
                    input[i].required = false;
                }
            } else {
                value.className = "";
                var input = value.getElementsByTagName("input");
                for (var i = 0; i < input.length; i++) {
                    input[i].required = true;
                }
            }
        }

    </script>
</head>
<body>
<form id="form" action="../productInfo/CreateFileInfo.php" target="_blank">
    <div style="background: #6BBE18;">
        fileInfo生成小工具
    </div>
    <div>
		<span>子商户所属类型：
		<input type="radio" name="Type" id="person" value="person">
		<lable for="person">个人</lable>
		<input type="radio" name="Type" id="individual" value="individual">
		<lable for="individual">个体</lable>
		<input type="radio" name="Type" id="enterprise" value="enterprise">
		<lable for="enterprise">企业</lable>
		</span>
    </div>
    <div>
        <table align="center" style="border:solid 1px #107929; margin-top: 20px;">
            <tr>
                <td rowspan="2">资质类型：</td>
                <td>
                    <input type="checkbox" name="quaType[]" id="IDCARD_FRONT" onclick="control(this)"
                           value="IDCARD_FRONT">1.法人身份证正面
                    <input type="checkbox" name="quaType[]" id="IDCARD_BACK" onclick="control(this)" value="IDCARD_BACK">2.法人身份证反面
                    <input type="checkbox" name="quaType[]" id="SETTLE_BANKCARD" onclick="control(this)"
                           value="SETTLE_BANKCARD">3.结算银行卡
                    <input type="checkbox" name="quaType[]" id="HAND_IDCARD" onclick="control(this)" value="HAND_IDCARD">4.手持身份证
                    <input type="checkbox" name="quaType[]" id="HAND_BANKCARD" onclick="control(this)"
                           value="HAND_BANKCARD">5.手持银行卡
                </td>
            </tr>
            <tr>
                <td><input type="checkbox" name="quaType[]" id="UNI_CREDIT_CODE" onclick="control(this)"
                           value="UNI_CREDIT_CODE">6.统一社会信用代码证
                    <input type="checkbox" name="quaType[]" id="OP_BANK_CODE" onclick="control(this)"
                           value="OP_BANK_CODE">7.银行开户许可证
                    <input type="checkbox" name="quaType[]" id="CORP_CODE" onclick="control(this)" value="CORP_CODE">8.营业执照
                    <input type="checkbox" name="quaType[]" id="TAX_CODE" onclick="control(this)" value="TAX_CODE">9.税务登记证
                    <input type="checkbox" name="quaType[]" id="ORG_CODE" onclick="control(this)" value="ORG_CODE">10.组织机构代码证

                </td>
            </tr>
    </div>
    <div>
		<span>支付场景：（可选项，主要取决于开通产品，没有开通此产品，则不选）
            <br>
		<input type="radio" name="Secence" id="APP" value="APP"><lable for="APP">APP接入</lable>
		<input type="radio" name="Secence" id="OPENID" value="OPENID"><lable for="OPENID">公众号接入</lable>
		<input type="radio" name="Secence" id="SHH" value="SHH"><lable for="SHH">支付宝生活号接入</lable>
        <input type="radio" name="Secence" id="POS" value="POS"><lable for="POS">POS接入</lable>
		<input type="radio" name="Secence" id="TS" value="TS"><lable for="TS">特殊行业接入</lable>
		<input type="radio" name="Secence" id="XX" value="XX"><lable for="XX">线下场景接入</lable>

		</span>
    </div>
    </table>
    </div>
    <div class="inputAreaDiv">
        <div id="IDCARD_FRONT_value" class="close">
            <table style="margin: 0">
                <tr>
                    <td style="border: none;">法人身份证正面资质地址：<input name="IDCARD_FRONT" style="width: 464px; "></td>
                </tr>
            </table>
        </div>
        <div id="IDCARD_BACK_value" class="close">
            <table style="margin: 0">
                <tr>
                    <td style="border: none;">法人身份证反面资质地址：<input name="IDCARD_BACK" style="width: 464px; "></td>
                </tr>
            </table>
        </div>
        <div id="CORP_CODE_value" class="close">
            <table style="margin: 0">
                <tr>
                    <td style="border: none;">营业执照资质地址：<input name="CORP_CODE" style="width: 464px; "></td>
                </tr>
            </table>
        </div>
        <div id="TAX_CODE_value" class="close">
            <table style="margin: 0">
                <tr>
                    <td style="border: none;">税务登记证资质地址：<input name="TAX_CODE" style="width: 464px; "></td>
                </tr>
            </table>
        </div>
        <div id="ORG_CODE_value" class="close">
            <table style="margin: 0">
                <tr>
                    <td style="border: none;">组织机构代码证资质地址：<input name="ORG_CODE" style="width: 464px; "></td>
                </tr>
            </table>
        </div>
        <div id="UNI_CREDIT_CODE_value" class="close">
            <table style="margin: 0">
                <tr>
                    <td style="border: none;">统一社会信用代码证资质地址：<input name="UNI_CREDIT_CODE" style="width: 464px; "></td>
                </tr>
            </table>
        </div>
        <div id="OP_BANK_CODE_value" class="close">
            <table style="margin: 0">
                <tr>
                    <td style="border: none;">银行开户许可证资质地址：<input name="OP_BANK_CODE" style="width: 464px; "></td>
                </tr>
            </table>
        </div>
        <div id="SETTLE_BANKCARD_value" class="close">
            <table style="margin: 0">
                <tr>
                    <td style="border: none;">结算银行卡资质地址：<input name="SETTLE_BANKCARD" style="width: 464px; "></td>
                </tr>
            </table>
        </div>
        <div id="HAND_IDCARD_value" class="close">
            <table style="margin: 0">
                <tr>
                    <td style="border: none;">手持身份证资质地址：<input name="HAND_IDCARD" style="width: 464px; "></td>
                </tr>
            </table>
        </div>
        <div id="HAND_BANKCARD_value" class="close">
            <table style="margin: 0">
                <tr>
                    <td style="border: none;">手持银行卡资质地址：<input name="HAND_BANKCARD" style="width: 464px; "></td>
                </tr>
            </table>
        </div>

        <div id="APP_HOME_PAGE_value" class="close app">
            <table style="margin: 0">
                <tr>
                    <td style="border: none;"><a style="color:red">APP首页截图地址：</a><input name="APP_HOME_PAGE"
                                                                                        style="width: 464px; "></td>
                </tr>
            </table>
        </div>
        <div id="APP_PRODUCT_PAGE_value" class="close app">
            <table style="margin: 0">
                <tr>
                    <td style="border: none;"><a style="color:red">APP产品页截图地址：</a><input name="APP_PRODUCT_PAGE"
                                                                                         style="width: 464px; "></td>
                </tr>
            </table>
        </div>
        <div id="APP_PRODUCT_DETAIL_value" class="close app">
            <table style="margin: 0">
                <tr>
                    <td style="border: none;"><a style="color:red">APP 产品详情截图地址：</a><input name="APP_PRODUCT_DETAIL"
                                                                                           style="width: 464px; "></td>
                </tr>
            </table>
        </div>

        <div id="APP_PURCHASE_value" class="close app">
            <table style="margin: 0">
                <tr>
                    <td style="border: none;"><a style="color:red">APP购买流程截图地址：</a><input name="AAPP_PURCHASE"
                                                                                          style="width: 464px; "></td>
                </tr>
            </table>
        </div>

        <div id="APP_PAYMENT_PROCESS_value" class="close app">
            <table style="margin: 0">
                <tr>
                    <td style="border: none;"><a style="color:red">APP支付流程截图地址：</a><input name="APP_PAYMENT_PROCESS"
                                                                                          style="width: 464px; "></td>
                </tr>
            </table>
        </div>

        <div id="APP_INSTALL_PACKAGE_value" class="close app">
            <table style="margin: 0">
                <tr>
                    <td style="border: none;"><a style="color:red">APP 安装包：</a><input name="APP_INSTALL_PACKAGE"
                                                                                      style="width: 464px; "></td>
                </tr>
            </table>
        </div>

        <div id="APP_EXTENSION_STATEMENT_value" class="close app">
            <table style="margin: 0">
                <tr>
                    <td style="border: none;"><a style="color:red">APP 推广声明：</a><input name="APP_EXTENSION_STATEMENT"
                                                                                       style="width: 464px; "></td>
                </tr>
            </table>
        </div>

        <div id="APP_AUTHORIZED_value" class="close app">
            <table style="margin: 0">
                <tr>
                    <td style="border: none;"><a style="color:red">APP手机客户端授权使用证：</a><input name="APP_AUTHORIZED"
                                                                                            style="width: 464px; "></td>
                </tr>
            </table>
        </div>


        <div id="WECHAT_OPENID_HOME_PAGE_value" class="close weChat">
            <table style="margin: 0">
                <tr>
                    <td style="border: none;"><a style="color:red">公众号产品首页截图地址：</a><input
                            name="WECHAT_OPENID_HOME_PAGE" style="width: 464px; "></td>
                </tr>
            </table>
        </div>
        <div id="WECHAT_OPENID_PRODUCT_PAGE_value" class="close weChat">
            <table style="margin: 0">
                <tr>
                    <td style="border: none;"><a style="color:red">公众号产品页截图地址：</a><input name="HWECHAT_OPENID_PRODUCT_PAGE"
                                                                                         style="width: 464px; "></td>
                </tr>
            </table>
        </div>
        <div id="WECHAT_OPENID_PRODUCT_DETAIL_value" class="close weChat">
            <table style="margin: 0">
                <tr>
                    <td style="border: none;"><a style="color:red">公众号产品详情截图地址：</a><input name="WECHAT_OPENID_PRODUCT_DETAIL"
                                                                                          style="width: 464px; "></td>
                </tr>
            </table>
        </div>
        <div id="WECHAT_OPENID_PURCHASE_value" class="close weChat">
            <table style="margin: 0">
                <tr>
                    <td style="border: none;"><a style="color:red">公众号购买页截图地址：</a><input name="WECHAT_OPENID_PURCHASE"
                                                                                         style="width: 464px; "></td>
                </tr>
            </table>
        </div>


        <div id="WECHAT_OPENID_PAYMENT_PROCESS_value" class="close weChat">
            <table style="margin: 0">
                <tr>
                    <td style="border: none;"><a style="color:red">公众号支付流程截图地址：</a><input
                            name="WECHAT_OPENID_PAYMENT_PROCESS" style="width: 464px; "></td>
                </tr>
            </table>
        </div>
        <div id="APP_AUTHORIZED_value" class="close weChat">
            <table style="margin: 0">
                <tr>
                    <td style="border: none;"><a style="color:red">手机客户端授权使用证明截图地址：</a><input name="APP_AUTHORIZED"
                                                                                              style="width: 464px; "></td>
                </tr>
            </table>
        </div>
        <div id="ZFB_SHH_HOME_PAGE_value" class="close ZFB">
            <table style="margin: 0">
                <tr>
                    <td style="border: none;"><a style="color:red">生活号首页截图地址：</a><input name="ZFB_SHH_HOME_PAGE"
                                                                                        style="width: 464px; "></td>
                </tr>
            </table>
        </div>
        <div id="ZFB_SHH_PRODUCT_PAGE_value" class="close ZFB">
            <table style="margin: 0">
                <tr>
                    <td style="border: none;"><a style="color:red">生活号产品页截图地址：</a>
                        <input name="ZFB_SHH_PRODUCT_PAGE" style="width: 464px; "></td>
                </tr>
            </table>
        </div>
        <div id="ZFB_SHH_PRODUCT_DETAIL_value" class="close ZFB">
            <table style="margin: 0">
                <tr>
                    <td style="border: none;"><a style="color:red">生活号产品详情截图地址：</a>
                        <input name="ZFB_SHH_PRODUCT_DETAIL" style="width: 464px; "></td>
                </tr>
            </table>
        </div>

        <div id="ZFB_SHH_PURCHASE_value" class="close ZFB">
            <table style="margin: 0">
                <tr>
                    <td style="border: none;"><a style="color:red">生活号购买页截图地址：</a>
                        <input name="ZFB_SHH_PURCHASE" style="width: 464px; "></td>
                </tr>
            </table>
        </div>


        <div id="ZFB_SHH_PAYMENT_PROCESS_value" class="close ZFB">
            <table style="margin: 0">
                <tr>
                    <td style="border: none;"><a style="color:red">生活号支付流程截图地址：</a>
                        <input name="ZFB_SHH_PAYMENT_PROCESS" style="width: 464px; "></td>
                </tr>
            </table>
        </div>

        <div id="APP_AUTHORIZED_value" class="close ZFB">
            <table style="margin: 0">
                <tr>
                    <td style="border: none;"><a style="color:red">手机客户端授权使用证明：</a>
                        <input name="APP_AUTHORIZED" style="width: 464px; "></td>
                </tr>
            </table>
        </div>

        <div id="APPLICATION_FORM_value" class="close wepos">
            <table style="margin: 0">
                <tr>
                    <td style="border: none;"><a style="color:red">公众号购买页截图地址：</a><input name="APPLICATION_FORM"
                                                                                         style="width: 464px; "></td>
                </tr>
            </table>
        </div>

        <div id="ATRADE_LICENSE_value" class="close wets">
            <table style="margin: 0">
                <tr>
                    <td style="border: none;"><a style="color:red">行业许可证：</a>
                        <input name="TRADE_LICENSE" style="width: 464px; "></td>
                </tr>
            </table>
        </div>


        <div id="BUSINESS_PLACE_value" class="close wex">
            <table style="margin: 0">
                <tr>
                    <td style="border: none;"><a style="color:red">经营场所门头照：</a>
                        <input name="BUSINESS_PLACE" style="width: 464px; "></td>
                </tr>
            </table>
        </div>

        <div id="CASHIER_SCENE_value" class="close wex">
            <table style="margin: 0">
                <tr>
                    <td style="border: none;"><a style="color:red">收银台场景照：</a>
                        <input name="CASHIER_SCENE" style="width: 464px; "></td>
                </tr>
            </table>
        </div>

        <div id="TRANSACTION_INVOICE_value" class="close wex">
            <table style="margin: 0">
                <tr>
                    <td style="border: none;"><a style="color:red">近3个月内交易发票：</a>
                        <input name="TRANSACTION_INVOICE" style="width: 464px; "></td>
                </tr>
            </table>
        </div>

        <div id="HAND_CORP_CODE_value" class="close wex">
            <table style="margin: 0">
                <tr>
                    <td style="border: none;"><a style="color:red">手持营业执照的门头照合：</a>
                        <input name="HAND_CORP_CODE" style="width: 464px; "></td>
                </tr>
            </table>
        </div>
    </div>
    <div style="border: none;">
        <span><input type="button" value="点击生成" id="submitButton"></span>
    </div>
    <input type="hidden" value="" id="hiddenJsonString" name="jsonString">
</form>
<script type="text/javascript" src="https://code.jquery.com/jquery-3.3.1.min.js"></script>
<script type="text/javascript">
    $(function () {
        $('input:radio[name=Secence]').change(function () {
            var value = $(this).val();
            if (value == 'OPENID') {
                $(".app").hide();
                $(".weChat").show();
                $(".ZFB").hide();
                $(".wepos").hide();
                $(".wets").hide();
                $(".wex").hide();
                return;
            }
            if (value == 'APP') {
                $(".app").show();
                $(".weChat").hide();
                $(".ZFB").hide();
                $(".wepos").hide();
                $(".wets").hide();
                $(".wex").hide();
                return;
            }
            if (value == 'SHH') {
                $(".app").hide();
                $(".weChat").hide();
                $(".ZFB").show();
                $(".wepos").hide();
                $(".wets").hide();
                $(".wex").hide();
                return;
            }
            if (value == 'POS') {
                $(".app").hide();
                $(".weChat").hide();
                $(".ZFB").hide();
                $(".wepos").show();
                $(".wets").hide();
                $(".wex").hide();
                return;

            }
            if (value == 'TS') {
                $(".app").hide();
                $(".weChat").hide();
                $(".ZFB").hide();
                $(".wepos").hide();
                $(".wets").show();
                $(".wex").hide();
                return;
            }
            if (value == 'XX') {
                $(".app").hide();
                $(".weChat").hide();
                $(".ZFB").hide();
                $(".wepos").hide();
                $(".wets").hide();
                $(".wex").show();
                return;
            }
        });


        $("#submitButton").click(function () {
            //首先校验类型
            var check_val = [];
            var type_val = [];
            var type = document.getElementsByName("Type");
            for (k in type) {
                if (type[k].checked)
                    type_val.push(type[k].value);
            }
            //alert("所选子商户类型："+type_val);
            var obj = document.getElementsByName("quaType[]");
            for (k in obj) {
                if (obj[k].checked)
                    check_val.push(obj[k].value);
            }
            // alert("所选资质类型："+check_val);
            for (var i = 0; i < type_val.length; i++) {
                if (type_val[i] == "person") {

                    var isContains = check_val.contains("IDCARD_FRONT") && check_val.contains("IDCARD_BACK") && check_val.contains("SETTLE_BANKCARD") && check_val.contains("HAND_IDCARD") && check_val.contains("HAND_BANKCARD");
                    if (!isContains) {
                        alert("如果注册类型为个人,则1,2,3,4,5为必选！");
                        return;
                    }
                }
                if (type_val[i] == "individual") {
                    var isContains = check_val.contains("IDCARD_FRONT") && check_val.contains("IDCARD_BACK") && check_val.contains("SETTLE_BANKCARD") && check_val.contains("CORP_CODE");
                    if (!isContains) {
                        alert("如果注册类型为个体,则1,2,3,8为必选！");
                        return;
                    }
                }
                if (type_val[i] == "enterprise") {
                    //CORP_CODE 、TAX_CODE 、ORG_CODE
                    var isContains = check_val.contains("IDCARD_FRONT") && check_val.contains("IDCARD_BACK") && check_val.contains("OP_BANK_CODE");
                    var isContains2 = check_val.contains("IDCARD_FRONT") && check_val.contains("IDCARD_BACK") && check_val.contains("CORP_CODE") && check_val.contains("TAX_CODE") && check_val.contains("OP_BANK_CODE") && check_val.contains("ORG_CODE");
                    var is_uni = check_val.contains("UNI_CREDIT_CODE");
                    if(is_uni){
                        if (!isContains) {
                            alert("如果注册类型为企业并 选择 统一社会信用代码证 ,则1,2,7为必选！");
                            return;
                        }
                    }
                    else{
                        if(!isContains2){
                            alert("如果注册类型为企业并 没有选择 统一社会信用代码证,则1,2,7,8,9,10为必选！");
                            return;
                        }
                    }
                }
            }

            var params = $(".inputAreaDiv input:visible");

            var objArr = new Array();
            for (var i = 0; i < params.length; i++) {
                var obj = new Object();
                obj.quaType = $(params[i]).attr("name");
                obj.quaUrl = $(params[i]).val();

                objArr.push(obj);
            }

            var jsonString = JSON.stringify(objArr);
            console.log(jsonString);

            $("#hiddenJsonString").val(jsonString);

            $("#form").submit();

        });


    });
</script>
</body>
</html>